<?
require_once "../php/Context.php";
require_once "../php/AdminInit.php";
if(!$admin->isAuthorize())
    echo "<script>document.location.href='../Admin.php';</script>";
?>
<!DOCTYPE html>
<html lang="en" ng-app="MainModule">

<head>

    <meta charset="utf-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1">
    <meta name="description" content="">
    <meta name="author" content="">

    <title>Admin panel</title>

    <link href="../AdminPanelFiles/css/bootstrap.min.css" rel="stylesheet">
    <link href="../AdminPanelFiles/css/sb-admin.css" rel="stylesheet">

    <link href="../css/easy-responsive-tabs.css" rel="stylesheet" type="text/css" media="all"/>
    <link href="../AdminPanelFiles/font-awesome/css/font-awesome.min.css" rel="stylesheet" type="text/css">
    <style>

        .resp-tab-content {
            border: none;
        }
        .category_table th{
            text-align: center;
            font-weight: bold;
            font-size: 20px;
        }
        .navbar-inverse .navbar-nav>li>a , .side-nav>li>ul>li>a, .navbar-inverse .navbar-brand,.top-nav>li>a{
            color: #ffffff;
            font-size: 16px;
        }
        .top-nav>li>a:hover, .top-nav>li>a:focus, .top-nav>.open>a, .top-nav>.open>a:hover, .top-nav>.open>a:focus,.side-nav li a:hover, .side-nav li a:focus{
            background-color: #C1C1C1 !important;
        }
        .my_alert{
            width:220px;
        }
        .navbar-inverse{
            background-color: #CC4646;
            border-color:  #CC4646;
        }
        .navbar-inverse .navbar-collapse, .navbar-inverse .navbar-form{
            border-color:  #CC4646;
        }
        .side-nav{
            background-color: #CC4646;
            height: 100%;
        }
        .navbar-inverse .navbar-nav>.active>a{
            background-color: #C1C1C1;
        }
        body,html{
            background-color: #ffffff;
            height: 100%;
        }
        #wrapper{
            height: 100%;
        }
        #page-wrapper{
            height: 100%;
            width: 1650px;
        }

    </style>


</head>

<body>

<div id="wrapper">
    <nav class="navbar navbar-inverse navbar-fixed-top" role="navigation">
        <!-- Brand and toggle get grouped for better mobile display -->
        <div class="navbar-header">
            <button type="button" class="navbar-toggle" data-toggle="collapse" data-target=".navbar-ex1-collapse">
                <span class="sr-only">Toggle navigation</span>
                <span class="icon-bar"></span>
                <span class="icon-bar"></span>
                <span class="icon-bar"></span>
            </button>
            <a class="navbar-brand" href="index.html">SB Admin</a>
        </div>
        <ul class="nav navbar-right top-nav">
            <li class="dropdown">

                <ul class="dropdown-menu message-dropdown">
                    <li class="message-preview">
                        <a href="#">
                            <div class="media">

                                <div class="media-body">
                                    <h5 class="media-heading"><strong>Admin</strong>
                                    </h5>
                                    <p class="small text-muted"><i class="fa fa-clock-o"></i> Yesterday at 4:32 PM</p>
                                    <p>Lorem ipsum dolor sit amet, consectetur...</p>
                                </div>
                            </div>
                        </a>
                    </li>
                    <li class="message-preview">
                        <a href="#">
                            <div class="media">
                                    <span class="pull-left">
                                        <img class="media-object" src="http://placehold.it/50x50" alt="">
                                    </span>
                                <div class="media-body">
                                    <h5 class="media-heading"><strong>Admin</strong>
                                    </h5>
                                    <p class="small text-muted"><i class="fa fa-clock-o"></i> Yesterday at 4:32 PM</p>
                                    <p>Lorem ipsum dolor sit amet, consectetur...</p>
                                </div>
                            </div>
                        </a>
                    </li>
                    <li class="message-preview">
                        <a href="#">
                            <div class="media">
                                    <span class="pull-left">
                                        <img class="media-object" src="http://placehold.it/50x50" alt="">
                                    </span>
                                <div class="media-body">
                                    <h5 class="media-heading"><strong>Admin</strong>
                                    </h5>
                                    <p class="small text-muted"><i class="fa fa-clock-o"></i> Yesterday at 4:32 PM</p>
                                    <p>Lorem ipsum dolor sit amet, consectetur...</p>
                                </div>
                            </div>
                        </a>
                    </li>
                    <li class="message-footer">
                        <a href="#">Read All New Messages</a>
                    </li>
                </ul>
            </li>

            <li class="dropdown">
                <a href="#" class="dropdown-toggle" data-toggle="dropdown"><i class="fa fa-user"></i> Admin<b class="caret"></b></a>
                <ul class="dropdown-menu">
                    <li>
                        <a href="../index.html"><i class="fa fa-fw fa-gear"></i> View website</a>
                    </li>
                    <li class="divider"></li>
                    <li>
                        <a href="../Admin.php?logout=true"><i class="fa fa-fw fa-power-off"></i> Log Out</a>
                    </li>
                </ul>
            </li>
        </ul>
        <div class="collapse navbar-collapse navbar-ex1-collapse">
            <ul class="nav navbar-nav side-nav">

                <li >
                    <a href="AdminPanel.php"><i class="fa fa-fw fa-edit"></i> Categories</a>
                </li>
                <li >
                    <a href="AdvertisingPanel.php"><i class="fa fa-fw fa-edit"></i> Advertising</a>
                </li>
                <li >
                    <a href="UserPanel.php"><i class="fa fa-fw fa-edit"></i> Users</a>
                </li>
                <li class="active">
                    <a href="ProductPanel.php"><i class="fa fa-fw fa-desktop"></i> Software Products</a>
                </li>
                <li>
                    <a href="javascript:;" data-toggle="collapse" data-target="#demo"><i class="fa fa-fw fa-arrows-v"></i> Other info <i class="fa fa-fw fa-caret-down"></i></a>
                    <ul id="demo" class="collapse">
                        <li>
                            <a href="SliderPanel.php">Slider items</a>
                        </li>
                        <li>
                            <a href="TelephonePanel.php">Telephone</a>
                        </li>
                    </ul>
                </li>
                <li>
                    <a href="NewsPanel.php"><i class="fa fa-fw fa-file"></i>News</a>
                </li>
                <li >
                    <a href="ContactsPanel.php"><i class="fa fa-fw fa-dashboard"></i> Contacts</a>
                </li>
            </ul>
        </div>

    </nav>

    <div id="page-wrapper" ng-controller="AdminCtrl">

        <div class="container-fluid">
            <div class="row">
                <div id="horizontalTab">
                    <ul class="resp-tabs-list">
                        <li>Software products</li>
                        <li>Add product</li>
                        <div class="clear"></div>
                    </ul>
                    <div class="resp-tabs-container">
                        <div class="col-lg-8">
                            <h1>Software products</h1>

                            <table class="table table-striped category_table" style="margin-top:40px;">
                                <thead>
                                <tr>
                                    <th style="display: none" class="test">#</th>
                                    <th>Title</th>
                                    <th>Download_link</th>
                                    <th style="display: none">Image_name</th>
                                    <th>File_size</th>
                                    <th>Download</th>
                                    <th style="display: none">Requirements</th>
                                    <th style="display: none">Languages</th>
                                    <th>Date_added</th>
                                    <th>Author</th>
                                    <th style="display: none">Home page</th>
                                    <th style="display: none">Description_preview</th>
                                    <th style="display: none">Description</th>
                                    <th style="display: none">Category Id</th>
                                    <th></th>
                                </tr>
                                </thead>
                                <tbody>
                                <tr ng-repeat="product in Products track by $index">
                                    <td style="display: none" width="60" scope="row"><input type="text" class="form-control" value="{{product.Id}}" disabled/> </td>
                                    <td><input class="form-control" type="text"  ng-disabled="enableProduct!=$index" ng-model="product.Title" /></td>
                                    <td><input class="form-control" type="text"  ng-disabled="enableProduct!=$index" ng-model="product.Download_link" /></td>
                                    <td style="display: none"><input class="form-control" type="text"  ng-disabled="enableProduct!=$index" ng-model="product.Image"  /></td>
                                    <td><input class="form-control" type="text"  ng-disabled="enableProduct!=$index" ng-model="product.File_size"  /></td>
                                    <td><input class="form-control" type="text"  ng-disabled="enableProduct!=$index" ng-model="product.Download"  /></td>
                                    <td style="display: none"><input class="form-control" type="text"  ng-disabled="enableProduct!=$index" ng-model="product.Requirements"  /></td>
                                    <td style="display: none"><input class="form-control" type="text"  ng-disabled="enableProduct!=$index" ng-model="product.Languages"  /></td>
                                    <td><input class="form-control" type="text"  ng-disabled="enableProduct!=$index" ng-model="product.Date_added"  /></td>
                                    <td><input class="form-control" type="text"  ng-disabled="enableProduct!=$index" ng-model="product.Author"  /></td>
                                    <td style="display: none"><input class="form-control" type="text"  ng-disabled="enableProduct!=$index" ng-model="product.Homepage"  /></td>
                                    <td style="display: none"><input class="form-control" type="text"  ng-disabled="enableProduct!=$index" ng-model="product.Description_preview"  /></td>
                                    <td style="display: none"><input class="form-control" type="text"  ng-disabled="enableProduct!=$index" ng-model="product.Description"  /></td>
                                    <td style="display: none"><input class="form-control" type="text"  disabled ng-model="product.CategoryId"  /></td>
                                    <?php
                                    $RoleId = $_SESSION['admin']['role'];
                                    if($RoleId == 1) {
                                        echo "<td><a ng-click=\"DeleteProduct(product)\" class=\"btn btn-success\" style=\"cursor: pointer\">Delete</a></td>";
                                    }
                                    ?>
                                    <td><a href="EditProduct.php?id={{product.Id}}" class="btn btn-success" style="cursor: pointer">Edit</a>

                                    </td>
                                    <td>
                                        <a  ng-click="addToSlider(product)" class="btn btn-success" style="cursor: pointer">AddToSlider</a>
                                    </td>
                                </tr>
                                </tbody>
                            </table>
                        </div>

                        <div class="review">
                            <div class="row">
                                <div class="col-lg-8">
                                    <div class="alert alert-success my_alert" ng-if="enableSuccess == true">
                                        <a  class="alert-link">Success! Data is Save.</a>
                                    </div>
                                    <form  action="../php/AddProduct.php" method="post" enctype="multipart/form-data">
                                        <table  class="product_table table table-striped product_table">
                                            <tr>
                                                <td class="title_category">Title product: </td>
                                                <td><input type="text" class="form-control" ng-model="Product_title" /></td>
                                            </tr>
                                            <tr>
                                                <td class="title_category">Download_link: </td>
                                                <td><input type="text" class="form-control" ng-model="Download_link" /></td>
                                            </tr>
                                            <tr>
                                                <td class="title_category">Image: </td>
                                                <td><input type="file" name="file" class="form-control" onchange="angular.element(this).scope().fileNameChanged(event)"/></td>
                                            </tr>
                                            <tr>
                                                <td class="title_category">File_size: </td>
                                                <td><input type="text" class="form-control" ng-model="Product_file_size" /></td>
                                            </tr>
                                            <tr>
                                                <td class="title_category">Requirements: </td>
                                                <td><input type="text" class="form-control" ng-model="Product_Requirements" /></td>
                                            </tr>
                                            <tr>
                                                <td class="title_category">Languages: </td>
                                                <td><input type="text" class="form-control" ng-model="Product_Languages" /></td>
                                            </tr>
                                            <tr>
                                                <td class="title_category">Date added: </td>
                                                <td><input type="text" class="form-control" ng-model="Product_Date" /></td>
                                            </tr>
                                            <tr>
                                                <td class="title_category">Author: </td>
                                                <td><input type="text" class="form-control" ng-model="Product_Author" /></td>
                                            </tr>
                                            <tr>
                                                <td class="title_category">Homepage: </td>
                                                <td><input type="text" class="form-control" ng-model="Product_page" /></td>
                                            </tr>
                                            <tr>
                                                <td class="title_category">Description_preview: </td>
                                                <td><textarea class="form-control" ng-model="Product_Description_preview" rows="3" cols="3" >

                                        </textarea></td>
                                            </tr>
                                            <tr>
                                                <td class="title_category">Description: </td>
                                                <td><textarea class="form-control" ng-model="Product_Description" rows="3" cols="3"></textarea></td>
                                            </tr>
                                            <tr>
                                                <td class="title_category">Category: </td>
                                                <td>
                                                    <select class="form-control" ng-options="category.Title for category in Categories" ng-model="Select_Category">
                                                    </select>
                                                </td>
                                            </tr>
                                            <tr>
                                                <td></td>
                                                <td><a  class="btn btn-success"  ng-click="AddProduct(Product_title,Download_link,Product_file_size,Product_Requirements,Product_Languages,Product_Date,Product_Author,Product_page,Product_Description_preview,Product_Description,Select_Category)">Send</a></td>
                                            </tr>
                                        </table>
                                    </form>
                                </div>
                            </div>
                        </div>
                    </div>
                </div>


            </div>
            <div class="row">
               <div class="col-lg-6">
                   <h1>Auto download</h1>
                   <table class="table table-striped category_table" >
                       <thead>
                       <tr>
                           <th class="test">#</th>
                           <th>Link</th>
                           <th>Time(1sec = 1000)</th>
                           <th></th>
                       </tr>
                       </thead>
                       <tbody>
                       <tr ng-repeat="link in Links track by $index">
                           <th scope="row"><input type="text" class="form-control" value="{{link.Id}}" disabled /> </th>
                           <td><input class="form-control" type="text"  ng-disabled="enableNews!=$index" ng-model="link.Link" /></td>
                           <td><input class="form-control" type="text"  ng-disabled="enableNews!=$index" ng-model="link.Time" /></td>
                           <td><a ng-hide="enableNews == $index"  ng-click="editNews($index)" class="btn btn-success" style="cursor: pointer">Edit</a>
                               <a ng-show="enableNews == $index" ng-click="saveLink(link)" class="btn btn-success" style="cursor: pointer">Save</a>
                           </td>
                       </tr>

                       </tbody>
                   </table>
               </div>
            </div>

        </div>

    </div>

</div>

<script src="../AdminPanelFiles/js/jquery.js"></script>
<script type="text/javascript" src="../js/move-top.js"></script>
<script type="text/javascript" src="../js/easing.js"></script>
<script src="../js/easyResponsiveTabs.js" type="text/javascript"></script>
<script src="../AdminPanelFiles/js/bootstrap.min.js"></script>
<script type="text/javascript">
    $(document).ready(function () {
        $('#horizontalTab').easyResponsiveTabs({
            type: 'default', //Types: default, vertical, accordion
            width: 'auto', //auto or any width like 600px
            fit: true   // 100% fit in a container
        });
    });
</script>
<script type="text/javascript" src="../js/angular.js"></script>
<script type="text/javascript" src="/js/AngularControllers/AdminCtrl.js"></script>
<script type="text/javascript" src="/js/AngularControllers/SliderCtrl.js"></script>
<script type="text/javascript" src="/js/AngularControllers/ReadMoreCtrl.js"></script>
<script type="text/javascript" src="/js/angularModules/mainModule.js"></script>
</body>
</html>
